﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Thor.Common.Test
{
    /// <summary>
    /// Tests methods of the Time class.
    /// </summary>
    [TestClass]
    public class TimeTest
    {
        #region Generated Code

        public TimeTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        #endregion

        [TestMethod]
        [Description("Time")]
        public void GetTimesTest()
        {
            var times = Time.GetTimes();

            int expected = 48;
            int actual = times.Count;

            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [Description("Time")]
        public void GetTimeByValueTest()
        {
            var time = Time.GetTime(1);

            Assert.IsNotNull(time);

            int expectedValue = 1;
            string expectedText = "12:00 AM";

            Assert.AreEqual(expectedValue, time.Value);
            Assert.AreEqual(expectedText, time.Text);
        }

        [TestMethod]
        [Description("Time")]
        public void GetTimeByTextTest()
        {
            var time = Time.GetTime("12:00 AM");

            Assert.IsNotNull(time);

            int expectedValue = 1;
            string expectedText = "12:00 AM";

            Assert.AreEqual(expectedValue, time.Value);
            Assert.AreEqual(expectedText, time.Text);
        }

        [TestMethod]
        [Description("Time")]
        public void GetTimeByDateTimeTest()
        {
            DateTime input = new DateTime(2010, 2, 19, 1, 0, 0);

            var time = Time.GetTime(input);

            Assert.IsNotNull(time);

            int expectedValue = 3;
            string expectedText = "1:00 AM";

            Assert.AreEqual(expectedValue, time.Value);
            Assert.AreEqual(expectedText, time.Text);
        }

        [TestMethod]
        [Description("Time")]
        public void GetTimeframeTest()
        {
            var times = Time.GetTimeframe(1, 24);

            Assert.IsNotNull(times);

            int expectedCount = 24;
            Assert.AreEqual(expectedCount, times.Count);
        }
    }
}
